package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.bean.FlowCellBean;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.lianzhihui.romeex.utils.LogUtil;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

import static com.lianzhihui.romeex.net.APIConstant.FLOW_CELL_INFO;

/**
 * Description:
 * Author: RAMON
 * CreateDate: 11/30/20 2:02 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class FlowCellModelImp {

    Context context;
    FlowCellInterface callback;

    public FlowCellModelImp(Context context, FlowCellInterface callback) {
        this.context = context;
        this.callback = callback;
    }

    /**
     * 流动池信息
     */
    public void getFolwCellInfo() {

        HttpParams params = new HttpParams();
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {

                FlowCellBean bean = GsonUtil.GsonToBean(o.getData(), FlowCellBean.class);

                callback.onFLInfo(bean);
            }

            @Override
            public void onError(ApiException e) {
                LogUtil.error("ramon",e.toString());
                callback.onFLInfoFail(e.getMessage());
            }
        }).post(FLOW_CELL_INFO, params);

    }

}
